const LOGIN_USER_KEY = 'sys:login:user'
const PC_USER_KEY = 'sys:pc:user'
const TOKEN_KEY = 'sys:login:token'

// Obj
const setObj = (key, obj) => {
  sessionStorage.setItem(key, JSON.stringify(obj))
}
const getObj = (key) => {
  return JSON.parse(sessionStorage.getItem(key))
}

// LoginUser
const setLoginUser = (user) => {
  sessionStorage.setItem(LOGIN_USER_KEY, JSON.stringify(user))
}
const getLoginUser = () => {
  return JSON.parse(sessionStorage.getItem(LOGIN_USER_KEY))
}

// PcUser
const setPcUser = (user) => {
  sessionStorage.setItem(PC_USER_KEY, JSON.stringify(user))
}
const getPcUser = () => {
  return JSON.parse(sessionStorage.getItem(PC_USER_KEY))
}

// Token
const setToken = (token) => {
  sessionStorage.setItem(TOKEN_KEY, token)
}
const getToken = () => {
  return sessionStorage.getItem(TOKEN_KEY)
}

// User sys:user:id

/*
  Article sys:article:id
  id
  userId
  critique:[id,id,id]

*/

/*
  Critique sys:critique:id
  id
  reply: {}
*/

export default {
  setObj,
  getObj,
  setLoginUser,
  getLoginUser,
  setPcUser,
  getPcUser,
  setToken,
  getToken,
}
